<template>
  <div class="app-container" id="app">
    <div class="div1">
      <h class="div1-hd"><i class="span1"></i>我的</h>
      <div class="div1-bd">
        <div class="div1-bd1">
          <div class="div1-bd1-b1" ><div class="aaa" ><img src="@/assets/images/1.png"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >排查任务完成率</span>
            <span @click="" style="display: block " class="spanclick">0.00%</span>
          </div>
        </div>
        <div class="div1-bd2">
          <div class="div1-bd1-b1" style="background-color: #5DD281"><div class="aaa" ><img src="@/assets/images/2.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >待排查任务</span>
            <span @click="dialogTableVisible = true" style="display: block " class="spanclick">{{this.yData[2]}}</span>
          </div>
        </div>
        <div class="div1-bd3" >
          <div class="div1-bd1-b1" style="background-color: #FF7373"><div class="aaa" ><img src="@/assets/images/3.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >待整改隐患</span>
            <span @click="dialogTableVisible11 = true" style="display: block " class="spanclick">0</span>
          </div>
        </div>
      </div>
    </div>
    <div class="div2">
      <h class="div2-hd"><i class="span1"></i>任务完成情况</h>
      <div class="div2-bd">
        <div class="span-a">
          <span style="margin-right: 10px">上周</span>
          <span style="margin-right: 10px">今日</span>
          <span style="margin-right: 10px">本周</span>
        </div>
        <div class="div2-bd1">
          <div class="div1-bd1-b1-1" style="background-color: #1597E9"><div class="bbb" ><img src="@/assets/images/4.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >应排查</span>
            <span @click="dialogTableVisibles = true" style="display: block " class="spanclick">{{this.yData[2]}}</span>
          </div>
        </div>
        <div class="div2-bd2">
          <div class="div1-bd1-b1-1" style="background-color: #5DD281"><div class="bbb" ><img src="@/assets/images/5.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >已排查</span>
            <span @click="dialogTableVisibles = true" style="display: block " class="spanclick" >{{this.yData[0]}}</span>
          </div>
        </div>
        <div class="div2-bd3" >
          <div class="div1-bd1-b1-1" style="background-color:#FCD466"><div class="bbb" ><img src="@/assets/images/6.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >未排查</span>
            <span @click="dialogTableVisibles = true" style="display: block " class="spanclick">{{this.yData[1]}}</span>
          </div>
        </div>
        <div class="div2-bd4" >
          <div class="div1-bd1-b1-1" style="background-color: #FF7373"><div class="bbb" ><img src="@/assets/images/7.jpg"></div></div>
          <div class="div1-bd1-b2" style="background-color: #efefef">
            <span >排查完成率</span>
            <span @click="" style="display: block " class="spanclick">0</span>
          </div>
        </div>
      </div>
    </div>
    <div class="div3">
      <h class="div1-hd"><i class="span1"></i>任务完成情况柱状图</h>
      <template>
        <div class="echart" id="mychart" :style="myChartStyle"></div>
      </template>
    </div>
<!--//我的-->
    <el-dialog title="待排查任务" :visible.sync="dialogTableVisible">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
        <el-form-item  prop="riskUnitName">
          <el-input
            v-model="queryParams.riskUnitName"
            placeholder="请输入风险单元"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          >
          </el-input>
        </el-form-item>
        <el-form-item  prop="hiddenDanger">
          <el-input
            v-model="queryParams.hiddenDanger"
            placeholder="请输入隐患排查内容"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-form-item>
        <el-table :data="screeningList">
          <el-table-column  label="风险单元" width="150" prop="riskUnitName"></el-table-column>
          <el-table-column  label="隐患排查内容" width="200" prop="hiddenDanger"></el-table-column>
          <el-table-column  label="开始时间" width="150" prop="firstCheckTime"></el-table-column>
          <el-table-column  label="结束时间" width="150" prop="lastCheckTime"></el-table-column>
        </el-table>
      </el-form>

    </el-dialog>
<!--    //待整改隐患-->
    <el-dialog title="待整改隐患" :visible.sync="dialogTableVisible11">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
        <el-form-item  prop="roleName">
          <el-input
            v-model="queryParams.roleName"
            placeholder="请选择隐患等级"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item  prop="roleKey">
          <el-input
            v-model="queryParams.roleKey"
            placeholder="请选择隐患类型"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item  prop="roleKey">
          <el-input
            v-model="queryParams.roleKey"
            placeholder="请选输入隐患状态"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-form-item>

      </el-form>
      <el-table :data="gridDatas11">
        <el-table-column  label="风险单元" width="150"></el-table-column>
        <el-table-column  label="隐患排查内容" width="200"></el-table-column>
        <el-table-column label="隐患名称" width="150"></el-table-column>
        <el-table-column  label="隐患等级" width="150"></el-table-column>
        <el-table-column  label="登记人" width="150"></el-table-column>
        <el-table-column  label="登记时间" width="150"></el-table-column>
        <el-table-column  label="隐患来源" width="150"></el-table-column>
        <el-table-column  label="治理类型" width="150"></el-table-column>
        <el-table-column  label="隐患类型" width="150"></el-table-column>

      </el-table>
    </el-dialog>
<!--    //任务完成情况-->
    <el-dialog title="应排查" :visible.sync="dialogTableVisibles">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
        <el-form-item  prop="riskUnitName">
          <el-input
            v-model="queryParams.riskUnitName"
            placeholder="请选择风险单元"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item  prop="hiddenDanger">
          <el-input
            v-model="queryParams.hiddenDanger"
            placeholder="请输入隐患排查内容"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-form-item>

      </el-form>
      <el-table :data="screeningList">
        <el-table-column  label="风险单元" width="200" prop="riskUnitName"></el-table-column>
        <el-table-column  label="风险事件" width="150" prop="eventName"></el-table-column>
        <el-table-column  label="隐患排查内容" width="150" prop="hiddenDanger"></el-table-column>
        <el-table-column  label="排查结果" width="150" prop="isChecked"></el-table-column>
        <el-table-column  label="实际排查时间" width="150" prop="realTime"></el-table-column>
        <el-table-column  label="开始时间" width="150"  prop="firstCheckTime"></el-table-column>
        <el-table-column  label="结束时间" width="150" prop="lastCheckTime"></el-table-column>
      </el-table>
    </el-dialog>

  </div>
</template>

<script>

import * as echarts from "echarts";
import {listChecked2,listAll} from "@/api/system/Statistics";
export default {


  data() {
    return {
      imgUrl:"@/assets/image/1.png",
      //树状图
      xData: [], //横坐标
      yData:[],//纵坐标
      totalData:[2,3,4],



      myChartStyle: { float: "left", width: "100%", height: "400px" }, //图表样式
      //查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        riskUnitName: undefined,
        hiddenDanger: undefined,
        isChecked:undefined,
        status: undefined
      },
      // 显示搜索条件
      showSearch: true,
      //我的任务表格
      screeningList: [],
      listChecked1:[],
      listChecked2:[],
      //任务完成情况表
      gridDatas:[{

      }],
      //隐患表
      gridDatas11:[{

      }],
      dialogTableVisibles: false,
      dialogFormVisibles: false,
      dialogTableVisible: false,
      dialogFormVisible: false,
      dialogTableVisible11: false,
      dialogFormVisible11: false,
    };
  },


  mounted() {

    this.getList();

  },

  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 查询我的排查任务列表 */
    getList() {
      this.loading = true;
        listAll(this.queryParams).then(response => {
          this.screeningList=response.data.key3;
        this.total=response.total;
          for (let i = 0; i <response.data.key5.length ; i++) {
            this.yData[i]=response.data.key5[i]
          }
          for (let i = 0; i <response.data.key4.length ; i++) {
            this.xData[i]=response.data.key4[i]
          }
          this.initEcharts();
        this.loading = false;


      });
    },

    /**
     * 查询
     */
    getAll(){
      listAll(this.queryParams).then(response => {
        this.listAll=response.row;
        this.total3 =response.total;
      })
    },

    initEcharts() {
      // 多列柱状图
      const mulColumnZZTData = {
        xAxis: {
          data: this.xData,
        },
        // 更改图例默认颜色(依次应用)
        color:['#1597E9', '#5DD281', '#FCD466'],
        // 图例
        legend: [{
          data: ["应排查任务", "已排查任务","未排查任务"],
          top: "0%",
        },
        ],
        yAxis: {},
        series: [
          {
            type: "bar", //形状为柱状图
            data: this.yData,
            barWidth: 30,
            itemStyle: {
              color: function (params) {
                let colorList = ['#1597E9', '#5DD281', '#FCD466']
                return colorList[params.dataIndex]
              }
            },
            name: "应排查任务", // legend属性
            label: {
              // 柱状图上方文本标签，默认展示数值信息
              show: true,
              position: "top",
            }
          },
          {
            type: "bar", //形状为柱状图
            // data: this.totalData,
            barWidth : 30,
            itemStyle: {
              color: function(params) {
                let colorList = ['#5DD281']
                return colorList[params.dataIndex]
              }
            },
            name: "已排查任务", // legend属性
            label: {
              // 柱状图上方文本标签，默认展示数值信息
              show: true,
              position: "top"
            }
          },
          {
            type: "bar", //形状为柱状图
            // data: this.totalData,
            barWidth : 30,
            itemStyle: {
              color: function(params) {
                let colorList = ['#FCD466']
                return colorList[params.dataIndex]
              }
            },
            name: "未排查任务", // legend属性
            label: {
              // 柱状图上方文本标签，默认展示数值信息
              show: true,
              position: "top"
            }
          }
        ]
      };

      const myChart = echarts.init(document.getElementById("mychart"));
      myChart.setOption(mulColumnZZTData);
      //随着屏幕大小调节图表
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    }

  }
};
</script>
<style scoped>

.div1{
  width: 590px;
  height: 320px;;
  float: left;
  box-shadow: 0 5px 5px 5px rgb(0 0 0 / 10%);

}
.div1-hd{
  display: inline-block;
  width: 100%;
  height: 40px;
  border-bottom: 1px solid #eee;
  line-height: 40px;

}
.div2-hd{
  display: inline-block;
  width: 100%;
  height: 40px;
  border-bottom: 1px solid #eee;
  line-height: 40px;
}
.span1{
  margin: -2px 10px 0 10px;
  display: inline-block;
  width: 5px;
  height: 20px;
  background-color: #1890ff;
  vertical-align: middle;
}
.spanclick{
  margin-top: 30px;
  cursor: pointer;
}
.span-a{
  position: absolute;
  right: 15px;
  top:10px;

}

.div1-bd{
  width: 100%;
  height: 290px;


}

.div1-bd1{
  overflow: hidden;
  width: 168px;
  height: 200px;
  float: left;
  margin:40px 10px 40px 20px;
  border-radius: 10px;
}
.div1-bd1-b1{
  height: 80px;
  background-color: #1597E9;
  padding-top: 20px ;
  padding-left: 56px;


}

.div1-bd1-b1-1{
  height: 80px;
  background-color: #1597E9;
  padding-top: 20px ;
  padding-left: 40px;


}
.div1-bd1-b2{
  height: 120px;
  text-align: center;
  padding-top: 15px;


}
.div1-bd2{
  width: 168px;
  height: 200px;
  background-color: #1ab394;
  float: left;
  margin:40px 10px;
  border-radius: 10px;
  overflow: hidden;
}
.div1-bd3{
  width: 168px;
  height: 200px;
  background-color: #b4bccc;
  float: left;
  margin:40px 10px;
  border-radius: 10px;
  overflow: hidden;
}
.div2{
  width: 590px;
  height: 320px;
  float: right;
  box-shadow: 0 5px 5px 5px rgb(0 0 0 / 10%);

}
.div2-bd{
  width: 100%;
  height: 290px;
  position: relative;

}
.div2-bd1{
  width: 120px;
  height: 200px;
  background-color: #1890ff;
  float: left;
  margin:40px 10px 40px 25px;
  border-radius: 10px;
  overflow: hidden;

}
.div2-bd2{
  width: 120px;
  height: 200px;
  background-color: #1890ff;
  float: left;
  margin:40px 10px ;
  border-radius: 10px;
  overflow: hidden;

}
.div2-bd3{
  width: 120px;
  height: 200px;
  background-color: #1890ff;
  float: left;
  margin:40px 10px ;
  border-radius: 10px;
  overflow: hidden;

}
.div2-bd4{
  width: 120px;
  height: 200px;
  background-color: #1890ff;
  float: left;
  margin:40px 10px ;
  border-radius: 10px;
  overflow: hidden;

}
.div3{
  width:1200px;
  height: 800px;;
  float: left;

  box-shadow: 0 5px 5px 5px rgb(0 0 0 / 10%);
  margin-top: 20px;

}



.echart{
  width: 1200px;
  height: 400px;
  float: left;
}

.div-s1{
  width: 30px;
  height: 60px;
  background: white;
}
.aaa{
  width: 60px;
  height: 60px;


}
.bbb{
  width: 55px;
  height: 55px;


}




</style>
